<?php

	include('includes/db_connect.php');

	switch ($_GET['act']) {
		case 1:
			$sql = "INSERT INTO categories (name) VALUES ('".$_POST['name']."')";
			// echo $sql;
			$query = mysql_query($sql);
			if ($query) {
				header('Location: categories.php');
			}
			break;
		case 2:
			$sql = "UPDATE categories SET name = '".$_POST['name']."' WHERE id = '".$_POST['id']."'";
			// echo $sql;
			$query = mysql_query($sql);
			if ($query) {
				header('Location: categories.php');
			}
			break;
		case 3:
			$sql = "DELETE FROM categories WHERE id = '".$_GET['id']."'";
			// echo $sql;
			$query = mysql_query($sql);
			if ($query) {
				header('Location: categories.php');
			}
			break;
	}


?>